package com.example.perpetualcalendar.viewModel;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;

import com.example.perpetualcalendar.domain.usecase.UseCase;

public abstract class BaseViewModel<U extends UseCase> extends ViewModel {

    public U useCase;

    protected BaseViewModel() {
        this.useCase = setUseCase();
    }

    @NonNull
    protected abstract U setUseCase();

    @Override
    protected void onCleared() {
        super.onCleared();
        if (useCase != null) {
            useCase.unsubscribe();
        }
    }
}
